﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using WordDocumentGenerator.Library;
namespace GPS.ENTITYS
{
    public class CrudModelQLPT
    {
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public decimal? STT { get; set; }
        public string PT_ID { get; set; }
        public string PT_BIENSO { get; set; }
        public string PT_DVGTVT_MA { get; set; }
        public string DVGTVT_TEN { get; set; }
        public string PT_SODK { get; set; }
        public string PT_COSOHUU { get; set; }
        public string PT_NHANHIEU { get; set; }
        public string PT_LOAIXE { get; set; }
        public string PT_MACXE { get; set; }
        public string PT_HANGXE { get; set; }
        public string PT_MAUXE { get; set; }
        public string PT_SOMAY { get; set; }
        public string PT_SOKHUNG { get; set; }
        public string PT_GPXTL { get; set; }
        public string PT_SOGPXTL { get; set; }
        public string PT_CQCAPGPXTL { get; set; }
        public string PT_NGAYGPXTL { get; set; }
        public string PT_NGAYHHGPXTL { get; set; }
        public string PT_NAMSX { get; set; }
        public string PT_COPHANHPHU { get; set; }
        public string PT_NGAYGCNKD { get; set; }
        public string PT_NGAYHHGCNKD { get; set; }
        public string PT_COBAOHIEM { get; set; }
        public string PT_TUYENDUONG { get; set; }
        public string PT_CHATLUONG { get; set; }
        public byte[] PT_ANHXE { get; set; }
        public string PT_ACTIVE { get; set; }
        public string PT_MOTA { get; set; }
    }
    public class EXPORTWORD_QLPT
    {
        public static byte[] EXPORT_QLPT(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);
            COMMON.ExportCore<CrudModelQLPT> docGenerator = new COMMON.ExportCore<CrudModelQLPT>(generationInfo);
            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;
            return generationInfo;
        }

    }
}
